using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class doctorMap : EntityTypeConfiguration<doctor>
    {
        public doctorMap()
        {
            // Primary Key
            this.HasKey(t => t.doctor_id);

            // Properties
            this.Property(t => t.doctor_id)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.name)
                .HasMaxLength(40);

            this.Property(t => t.id_number)
                .HasMaxLength(20);

            this.Property(t => t.post_code)
                .HasMaxLength(6);

            this.Property(t => t.family_phone)
                .HasMaxLength(20);

            this.Property(t => t.section_office)
                .HasMaxLength(50);

            this.Property(t => t.office_phone)
                .HasMaxLength(20);

            this.Property(t => t.title)
                .HasMaxLength(50);

            this.Property(t => t.mobile_phone)
                .HasMaxLength(20);

            this.Property(t => t.personal_website)
                .HasMaxLength(100);

            this.Property(t => t.doctor_desc)
                .HasMaxLength(50);

            this.Property(t => t.email)
                .HasMaxLength(50);

            this.Property(t => t.expert_id)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("doctor");
            this.Property(t => t.doctor_id).HasColumnName("doctor_id");
            this.Property(t => t.type_flag).HasColumnName("type_flag");
            this.Property(t => t.name).HasColumnName("name");
            this.Property(t => t.gender).HasColumnName("gender");
            this.Property(t => t.id_number).HasColumnName("id_number");
            this.Property(t => t.birthday).HasColumnName("birthday");
            this.Property(t => t.post_code).HasColumnName("post_code");
            this.Property(t => t.family_phone).HasColumnName("family_phone");
            this.Property(t => t.section_office).HasColumnName("section_office");
            this.Property(t => t.office_phone).HasColumnName("office_phone");
            this.Property(t => t.title).HasColumnName("title");
            this.Property(t => t.mobile_phone).HasColumnName("mobile_phone");
            this.Property(t => t.personal_website).HasColumnName("personal_website");
            this.Property(t => t.doctor_desc).HasColumnName("doctor_desc");
            this.Property(t => t.status).HasColumnName("status");
            this.Property(t => t.node_id).HasColumnName("node_id");
            this.Property(t => t.email).HasColumnName("email");
            this.Property(t => t.expert_id).HasColumnName("expert_id");

            // Relationships
            this.HasRequired(t => t.node)
                .WithMany(t => t.doctors)
                .HasForeignKey(d => d.node_id);

        }
    }
}
